package com.selfdriving.activity;

import java.util.ArrayList;
import java.util.List;

import net.tsz.afinal.annotation.view.ViewInject;

import com.selfdriving.R;
import com.selfdriving.adapter.FeatureListAdapter;
import com.selfdriving.bean.Feature;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;

public class PopularListActivity extends BaseActivity {
	@ViewInject(id = R.id.feature_list)
	ListView feature_list;
	
	@ViewInject(id=R.id.spinner_1)
	private Spinner spinner;
	
	@ViewInject(id=R.id.spinner_2)
	Spinner spinner1;
	
	@ViewInject(id=R.id.spinner_3)
	Spinner spinner2;

	private FeatureListAdapter adapter;

	private List<Feature> features;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View contentView = LayoutInflater.from(getParent().getParent()).inflate(R.layout.popular_list, null);
		setContentView(contentView);
		ArrayAdapter<String> cityAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.city));
		ArrayAdapter<String> featureAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.feature_sort));
		ArrayAdapter<String> levelAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.feature_level));
		cityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
		featureAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
		levelAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
        spinner.setAdapter(cityAdapter);
        spinner1.setAdapter(featureAdapter);
        spinner2.setAdapter(levelAdapter);
		
		features = new ArrayList<Feature>();
		for (int i = 0; i < 10; i++) {
			Feature feature = new Feature();
			switch (i) {
			case 0:
				feature.name = "温泉";
				feature.popularNum = "13365";
				break;
			case 1:
				feature.name = "庐山";
				feature.popularNum = "12365";
				break;
			case 2:
				feature.name = "明月山";
				feature.popularNum = "12300";
				break;
			case 3:
				feature.name = "龙虎山";
				feature.popularNum = "12200";
				break;
			case 4:
				feature.name = "三清山";
				feature.popularNum = "10000";
				break;
			default:
				break;
			}
			features.add(feature);
		}
		adapter = new FeatureListAdapter(this, features);
		feature_list.setAdapter(adapter);
		feature_list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent intent = new Intent(PopularListActivity.this, FeatureDetailsActivity.class);
				startActivity(intent);
			}
		});
	}

}
